package org.loofer.ext.component.info;

import java.util.HashMap;

enum AccessPoint {
    NONE("", ServiceProvider.NONE, false),
    NEVER_HEARD("I don't know", ServiceProvider.NEVER_HEARD, false),
    CMNET("cmnet", ServiceProvider.CHINA_MOBILE, false),
    CMWAP("cmwap", ServiceProvider.CHINA_MOBILE, true),
    UNINET("uninet", ServiceProvider.CHINA_UNICOM, false),
    UNIWAP("uniwap", ServiceProvider.CHINA_UNICOM, true),
    _3GNET("3gnet", ServiceProvider.CHINA_UNICOM, false),
    _3GWAP("3gwap", ServiceProvider.CHINA_UNICOM, true),
    CTNET("ctnet", ServiceProvider.CHINA_TELECOM, false),
    CTWAP("ctwap", ServiceProvider.CHINA_TELECOM, true),
    SHARP777("#777", ServiceProvider.CHINA_TELECOM, false);
    
    private static HashMap<String, AccessPoint> ACCESS_POINT_MAP;
    private String name;
    private ServiceProvider provider;
    private boolean wap;

    static {
        ACCESS_POINT_MAP = new HashMap();
        AccessPoint[] values = values();
        int length = values.length;
        int i;
        while (i < length) {
            AccessPoint accessPoint = values[i];
            ACCESS_POINT_MAP.put(accessPoint.getName(), accessPoint);
            i++;
        }
    }

    private AccessPoint(String name, ServiceProvider provider, boolean isWap) {
        setName(name);
        setProvider(provider);
        setWap(isWap);
    }

    public static AccessPoint forName(String name) {
        if (name == null) {
            return NONE;
        }
        AccessPoint accessPoint = (AccessPoint) ACCESS_POINT_MAP.get(name.toLowerCase());
        return accessPoint == null ? NEVER_HEARD : accessPoint;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ServiceProvider getProvider() {
        return this.provider;
    }

    public void setProvider(ServiceProvider provider) {
        this.provider = provider;
    }

    public boolean isWap() {
        return this.wap;
    }

    public void setWap(boolean wap) {
        this.wap = wap;
    }
}
